package com.itheima.controller;

import com.itheima.pojo.Project;
import com.itheima.pojo.Result;
import com.itheima.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RequestMapping("/project")
@RestController
public class ProjectController {
    @Autowired
    private ProjectService projectService;

    @RequestMapping("/addProject")
    public Result addProject(@RequestBody Project project) {
        projectService.addProject(project);
        return Result.success();
    }

    @RequestMapping("/getProjectList")
    public Result getProjectList() {
        List<Project> projectList = projectService.getProjectList();
        return Result.success(projectList);
    }

    @RequestMapping("/changeKahuna")
    public Result changeKahuna(@RequestBody Project project) {
        Integer id = project.getId();
        String kahunaName = project.getName();
        return Result.success();
    }
    @RequestMapping("/deleteProject")
    public Result deleteProject(@RequestBody Project project){
        System.out.println("project:"+project);

        return projectService.deleteProject(project);
    }
}
